import java.util.Scanner;

class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;
    public TreeNode(int val) {
        this.val = val;
    }
}
class Solution1 {
    public TreeNode Mirror(TreeNode root) {
        if(root==null){
            return root;
        }
        if(root.left==null&&root.right==null){
            return root;
        }
        TreeNode tmp=root.left;
        root.left=root.right;
        root.right=tmp;
        Mirror(root.left);
        Mirror(root.right);
        return root;
    }
    public TreeNode dfs(TreeNode root){
        if(root.left==null&&root.right==null){
            return null;
        }
        if(root.left!=null&&root.right==null){
            root.right=root.left;
            root.left=null;
        }else if(root.left==null&&root.right!=null){
            root.left=root.right;
            root.right=null;
        }else{
            TreeNode tmp=root.left;
            root.left=root.right;
            root.right=tmp;
        }
        dfs(root.left);
        dfs(root.right);
        return root;
    }
}













public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            int n= scanner.nextInt();
            if(n<=2){
                System.out.println(-1);
            }else if(n%2==1){
                System.out.println(2);
            }else{
                if(n%4==0){
                    System.out.println(3);
                }else{
                    System.out.println(4);
                }
            }
        }
    }
}